/**
 * TetrisController.h
 * Cocoa Tetris
 *
 * Copyright 2009 Wei Yeh, Evelyn Yung. All rights reserved.
 */

#import <Cocoa/Cocoa.h>
#import "Board.h"
#import "MiniBoard.h"
#import "Cell.h"
#import "Tetromino.h"

@interface TetrisController : NSObject {
	IBOutlet Board *board;
	IBOutlet MiniBoard *miniboard;
	
	IBOutlet NSTextField *score;
	IBOutlet NSTextField *rowsCleared;
	IBOutlet NSTextField *level;
	IBOutlet NSWindow *levelSheet;
	IBOutlet NSWindow *window;
	IBOutlet NSPopUpButton *difficulty;
	IBOutlet NSButton *mainButton;
	IBOutlet NSMenu *popupMenu;
	
	int state;
	Tetromino *activeTetromino;
	Tetromino *nextTetromino;
	float speed;
	NSTimer *tickTimer;
	
	NSSound *musicBackground;
	NSSound *soundRotate;
	NSSound *soundClearing;
	NSSound *soundTetris;
}

-(id) init;
-(IBAction)newGame:(id)sender;
-(void)pauseGame;
-(void)resumeGame;
-(IBAction)openSheet:(NSMenuItem*)item;
-(void)didEndSheet:(NSWindow*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo;
-(IBAction)cancel:(id)sender; 
-(IBAction)changeLevel:(id)sender; 
-(void)setUpGame;
-(void)startTick;
-(void)stopTick;
-(void)tick:(NSTimer*)timer;
/** Command dispatch. */
-(void)move:(unichar)key;
-(void)updateStats:(unsigned int)numCleared;
-(int)state;

@end

Board* tetrisBoard;
MiniBoard* tetrisMiniBoard;
TetrisController* controller;
